Is it clear what the phrase "the object a" means?
Yes, even though the phrase is a little bit deceptive.
One should really say "the object referenced by a
,"
or "the object referred to by a,"
but often people use the shorter phrase and expect you to know what they mean.
toString()
Method
The example program does very little that is visible on the monitor screen.
It would be nice to print something out.
The bytes that make up an object cannot be sent directly to the monitor because
they are not usually ASCII character data.
For example, the two ints
of a Point use a data type that
can't be sent directly to a monitor.
Of course, the methods of an object are in Java bytecode, which makes no sense
to a monitor, either.
Luckily, there is a method defined in class
Point
that can be used to create a printable String for a Point object:
public String toString(); // returns character data that can be printed | | | | | +--- this is the method name. It takes no parameters. | | | +--- this says that the method returns a String object | +--- anywhere you have a Point object, you can use this method
The toString()
method of a Point object creates a
String object.